package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Lrizhi;
import cn.gson.fengboot.model.service.LrizhiService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/vue")
public class LrizhiController {
    @Autowired
    LrizhiService lrizhiService;

    //查询所有客户的服务
    @RequestMapping("/Lrizhicx")
    @ResponseBody
    public Map<String,Object> Lrizhicx(Integer currentPage , Integer pageSize, String search, String fenlei){
        if(currentPage==null || currentPage==' '||pageSize==null||pageSize==' '){
            currentPage=1;
            pageSize=5;
        }
        Page<Object> obj= PageHelper. startPage(  currentPage, pageSize);
        List<Lrizhi> lrizhis = lrizhiService.Lrizhicx(search,fenlei);
        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("row",lrizhis);
        return map;
    }

    //新增客户服务信息
    @RequestMapping("/addLrizhi")
    @ResponseBody
    public  void addLrizhi(@RequestBody Lrizhi lrizhi){
        lrizhiService.addLrizhi(lrizhi);
    }

    //
    @RequestMapping("/rizhilx")
    @ResponseBody
    public Map<String ,Object> Lrizhilx(String vv){
        Map<String,Object> map= null;
        if (vv.equals("日志类型分布")){
            map= lrizhiService.Lrizhilx();
        }
        else if (vv.equals("人员日志数量分布")){
            map= lrizhiService.Lrzygcs();
        }
        return map;
    }
}
